#ifndef __NETCAPTURE_H__
#define __NETCAPTURE_H__
#include <pthread.h>
#include <stdbool.h>
#include <time.h>
#include "NetCore.h"
#include "NetWorkService.h"
#include "NetSIVnPdu.h"
#include "hi_mw_media_intf.h"
#include "Sqlist_List.h"
#include "IBT_List.h"
#include "Svc_BaseTypedef.h"



#define MAX_PFRAME_DROP 200

typedef struct _frames_adapter_a_
{
    int emAdjustState[N_SYS_CH*2];
    int iPFrameNums[N_SYS_CH*2];/*统计p帧数目，-1 wait to send i frame*/
    int iFpsAdapter[N_SYS_CH*2];/* 网络发帧调整0 :normal 1: adapter, normal期间数据是按包发, 如有整帧存的话按帧发*/
    struct timeval stLastTime[N_SYS_CH*2];
}PER_CONN_NET_FRAME_ADAPTER;






typedef struct CCapture
{
	//一个conn 保存链接的消息，后面做弹出使用，保存通道是开启上传还是结束上传状态
	struct conn *m_conn;
	char m_MonitorState;  //保存对应码流通道的状态,新增成员的时候设置为0
	List_Head Head;
}CCapture;



typedef struct CNet_Packet			//网络视频包
{
	unsigned char* 		 m_Buffer; 	//数据
	unsigned long int 	 m_length; 	//数据长度
	unsigned char 		 Frame_Type; 	//帧类型
	int 				 m_pakc_num; //绑定人数的，为0时候进行free,需要free数据buff和结构体指针内存
	pthread_mutex_t 	 m_mutex; 	//防止更新数据时候读取数据，数据包锁
	IBTList				queue;		//链表
}CNet_Packet;




typedef struct __CCapture_List	//网络传输
{
	bool 			m_Capture_Swich;		//上传线程开关
	pthread_t 		m_Update_pthread_Id;	//上传线程号
	pthread_mutex_t m_Capture_hmutex;		//捕获人员添加和删除锁
	int 			m_Capture_Number;		//捕获开启人数
	int 			m_Connect_Number;		//链接人数
	CCapture 		m_Capture_Head;			//捕获人员
	IBTListQueue 	m_Packet_Queue;			//视频包队列
}CCapture_List;



typedef struct __Capture_config
{
	int pic_width;		// 图像宽度
	int pic_height;		// 图像高度
	int frame_rate;		// 帧率
	
	
}Capture_config;


void Net_gCaptureList_Init();  
//void NetCapture_AddNumber(struct conn *p_conn);
void NetCapture_DeleteNumber(struct conn *p_conn);//应对不正常退出比如产测崩溃
int Capture_FilterCallback(struct conn *c, DVRIP *pHead);
int FormStandHead(unsigned char *buf,int framelen,int headtype,time_t times);













#endif
